import { NextApiRequest, NextApiResponse } from 'next';

import redis from '../../lib/redisClient';
import prisma from '../../lib/prisma';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
    try {
        // 设置键值对
        await redis.set('greeting', 'Hello, Redis!');
        const user = await prisma.user.findMany();
        // 获取值
        const value = await redis.get('greeting');
    
        res.status(200).json({ message: value, user });
      } catch (error) {
        console.error('Redis 错误：', error);
        res.status(500).json({ error: '服务器内部错误' });
      }
}